package du.com.linandroid;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import com.du.linandroid.callback.CallBack;
import com.du.linandroid.util.LLog;
import com.du.linandroid.biz.Lin;
import com.du.linandroid.callback.ShareCallBack;

import org.json.JSONObject;

public class MainActivity extends Activity {
    public static final String WECHAT_APPID = "";
    public static final String WECHAT_SECRET = "";
    public static final String QQ_APPID = "";
    public static final String QQ_SECRET = "";
    public static final String WEIBO_KEY = "";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Lin.init(this , WECHAT_APPID , WECHAT_SECRET , QQ_APPID , QQ_SECRET , WEIBO_KEY);
    }

    public void click(View view) {
        Lin.wechatLogin(new CallBack() {
            @Override
            public void start() {
                LLog.d("login start");
            }

            @Override
            public void success(JSONObject jsonObject) {
                LLog.d("login success : " + jsonObject.toString());
            }

            @Override
            public void fail(JSONObject jsonObject) {
                LLog.d("login fail:" + jsonObject.toString());
            }

            @Override
            public void complete() {
                LLog.d("login complete");
            }
        });
    }

    public void share(View view) {
        Lin.wechatTextShare(true, "hi", new ShareCallBack() {
            @Override
            public void success(JSONObject jsonObject) {
                LLog.d(jsonObject.toString());
                LLog.d("success");
            }

            @Override
            public void fail(JSONObject jsonObject) {
                LLog.d(jsonObject.toString());
                LLog.d("fail");
            }
        });
    }

    public void qqlogin(View view) {
        Lin.qqLogin(this, new CallBack() {
            @Override
            public void start() {
                LLog.d("qq login start");
            }

            @Override
            public void success(JSONObject jsonObject) {
                LLog.d("qq login success :" + jsonObject.toString());
            }

            @Override
            public void fail(JSONObject jsonObject) {
                LLog.d("qq login fail :" + jsonObject.toString());
            }

            @Override
            public void complete() {
                LLog.d("qq login complete");
            }
        });
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        Lin.onActivityResult(requestCode , resultCode , data);
    }

    public void qqShare(View view) {
        Lin.qqShare("hello world", "I'm body!", "https://www.baidu.com/img/pcse_small.png","https://www.baidu.com",  new ShareCallBack() {
            @Override
            public void success(JSONObject jsonObject) {
                LLog.d("qq share success :" + jsonObject.toString());
            }

            @Override
            public void fail(JSONObject jsonObject) {
                LLog.d("qq share fail :" + jsonObject.toString());
            }
        });
    }


}
